package guo.util;

import java.util.HashMap;

public class R<T> extends HashMap<String,Object> {
    private T data;

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public R(){
        put("code",0);
        put("msg","success");
    }

    public Integer getCode(){
        return (Integer) get("code");
    }

    public static R ok(String msg) {
        R r = new R();
        r.put("msg", msg);
        return r;
    }

    public static R ok() {
        return new R();
    }

    public R put(String key, Object value) {
        super.put(key, value);
        return this;
    }

    @Override
    public String toString() {
        return "R{" +
                "data=" + data +
                '}';
    }
}
